home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / vista.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  6KB  |  165 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from gui.textutil import default_font
  5. from gui.toolbox import TransparentBitmap
  6. import ctypes
  7. import wx
  8. from util import do
  9. dwm = ctypes.windll.dwmapi
  10. ux = ctypes.windll.uxtheme
  11. from ctypes.wintypes import RECT, DWORD, BOOL, HRGN, COLORREF, POINT, LPARAM
  12. from ctypes import byref, c_int32, c_void_p, Structure
  13. adjusted_controls = [
  14.     wx.StaticText,
  15.     wx.CheckBox,
  16.     wx.TextCtrl,
  17.     wx.Button,
  18.     wx.HyperlinkCtrl,
  19.     wx.StaticBox,
  20.     wx.RadioBox,
  21.     wx.RadioButton,
  22.     wx.Choice,
  23.     wx.ComboBox,
  24.     wx.FilePickerCtrl,
  25.     wx.DirPickerCtrl]
  26. from wx.py.editwindow import FACES
  27. FACES['mono'] = 'Consolas'
  28.  
  29. def _change_font(ctrl):
  30.     oldinit = ctrl.__init__
  31.     
  32.     def newinit(self, *a, **k):
  33.         
  34.         try:
  35.             oldinit(self, *a, **k)
  36.         except:
  37.             funcinfo = funcinfo
  38.             import util
  39.             import sys as sys
  40.             print >>sys.stderr, '_change_font failed at %s' % funcinfo(oldinit)
  41.             raise 
  42.  
  43.         self.SetFont(default_font())
  44.  
  45.     ctrl.__init__ = newinit
  46.  
  47. for ctrl in adjusted_controls:
  48.     _change_font(ctrl)
  49.  
  50.  
  51. class DWM_BLURBEHIND(Structure):
  52.     _fields_ = [
  53.         ('dwFlags', DWORD),
  54.         ('fEnable', BOOL),
  55.         ('hRgnBlur', HRGN),
  56.         ('fTransitionOnMaximized', BOOL)]
  57.  
  58.  
  59. class DTTOPTS(Structure):
  60.     _fields_ = [
  61.         ('dwSize', DWORD),
  62.         ('dwFlags', DWORD),
  63.         ('crText', COLORREF),
  64.         ('crBorder', COLORREF),
  65.         ('crShadow', COLORREF),
  66.         ('iTextShadowType', c_int32),
  67.         ('ptShadowOffset', POINT),
  68.         ('iBorderSize', c_int32),
  69.         ('iFontPropId', c_int32),
  70.         ('iColorPropId', c_int32),
  71.         ('iStateId', c_int32),
  72.         ('fApplyOverlay', BOOL),
  73.         ('iGlowSize', c_int32),
  74.         ('pfnDrawTextCallback', c_void_p),
  75.         ('lParam', LPARAM)]
  76.  
  77. DWM_BB_ENABLE = 1
  78. DWM_BB_BLURREGION = 2
  79. DWM_BB_TRANSITIONONMAXIMIZED = 4
  80.  
  81. def glassExtendInto(win, left = -1, right = -1, top = -1, bottom = -1):
  82.     rect = RECT(left, right, top, bottom)
  83.     if IsCompositionEnabled():
  84.         dwm.DwmExtendFrameIntoClientArea(win.Handle, byref(rect))
  85.         return True
  86.     else:
  87.         return False
  88.  
  89.  
  90. def glassBlurRegion(win, region = 0):
  91.     bb = DWM_BLURBEHIND()
  92.     bb.dwFlags = DWM_BB_ENABLE
  93.     bb.fEnable = 1
  94.     bb.hRgnBlur = region
  95.     return dwm.DwmEnableBlurBehindWindow(win.Handle, byref(bb))
  96.  
  97.  
  98. def IsCompositionEnabled():
  99.     enabled = c_int32(0)
  100.     dwm.DwmIsCompositionEnabled(byref(enabled))
  101.     return bool(enabled)
  102.  
  103.  
  104. class ThemeMixin(object):
  105.     
  106.     def __init__(self, window):
  107.         self._hTheme = ux.OpenThemeData(window.Handle, u'globals')
  108.         print 'hTheme', self._hTheme
  109.  
  110.     
  111.     def __del__(self):
  112.         ux.CloseThemeData(self._hTheme)
  113.  
  114.  
  115. DTT_COMPOSITED = 8192
  116. DTT_GLOWSIZE = 2048
  117. DTT_TEXTCOLOR = 1
  118. DT_TOP = 0
  119. DT_LEFT = 0
  120. DT_CENTER = 1
  121. DT_RIGHT = 2
  122. DT_VCENTER = 4
  123. DT_WORDBREAK = 16
  124. DT_SINGLELINE = 32
  125. DT_NOPREFIX = 2048
  126.  
  127. def DrawThemeTextEx(win, handle, text):
  128.     dto = DTTOPTS()
  129.     uFormat = DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX
  130.     dto.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE
  131.     dto.iGlowSize = 10
  132.     rcText2 = RECT(0, 0, 150, 30)
  133.     ux.DrawThemeTextEx(win._hTheme, handle, 0, 0, unicode(text), -1, uFormat, byref(rcText2), byref(dto))
  134.  
  135.  
  136. class ThemedFrame(wx.Frame, ThemeMixin):
  137.     
  138.     def __init__(self, *a, **k):
  139.         wx.Frame.__init__(self, *a, **k)
  140.         ThemeMixin.__init__(self, self)
  141.  
  142.  
  143. if __name__ == '__main__':
  144.     app = wx.PySimpleApp()
  145.     f = ThemedFrame(None)
  146.     f.Sizer = sz = wx.BoxSizer(wx.VERTICAL)
  147.     
  148.     def paint(e):
  149.         dc = wx.PaintDC(f)
  150.         dc.Brush = wx.BLACK_BRUSH
  151.         dc.Pen = wx.TRANSPARENT_PEN
  152.         bmap = TransparentBitmap(f.Size)
  153.         dc2 = wx.MemoryDC()
  154.         dc2.SelectObject(bmap)
  155.         dc2.Font = default_font()
  156.         dc2.TextForeground = wx.RED
  157.         dc2.DrawText('hello', 0, 0)
  158.         dc.DrawBitmap(bmap, 0, 0)
  159.         e.Skip(True)
  160.  
  161.     f.Bind(wx.EVT_PAINT, paint)
  162.     f.Show(True)
  163.     app.MainLoop()
  164.  
  165.